package main

import (
	"HomeStation/controllers"
	_ "HomeStation/controllers"
	_ "HomeStation/db"
	_ "HomeStation/routers"
	"encoding/json"
	"net/http"

	beego "github.com/beego/beego/v2/server/web"
)

func handler_page_not_found(responst http.ResponseWriter, request *http.Request) {
	print("进入错误了")
	mssage, _ := json.Marshal(controllers.Response{Code: 404, Message: "页面请求错误"})
	responst.Write(mssage)
}

///主入口方
func main() {
	beego.BConfig.WebConfig.Session.SessionOn = true
	beego.BConfig.WebConfig.Session.SessionProvider = "file"
	beego.BConfig.WebConfig.Session.SessionProviderConfig = "./.cache/session"
	beego.ErrorHandler("401", handler_page_not_found)
	beego.ErrorHandler("403", handler_page_not_found)
	beego.ErrorHandler("404", handler_page_not_found)
	beego.ErrorHandler("500", handler_page_not_found)
	beego.ErrorHandler("503", handler_page_not_found)
	beego.SetStaticPath("app", "app")
	beego.SetViewsPath("app")
	beego.Run()
}
